import {
  Body,
  ClassSerializerInterceptor,
  Controller,
  Get,
  Post,
  Res,
  UseInterceptors,
} from '@nestjs/common';
import { AuthService } from './auth.service';
import { CreateUserDto } from '../user/dto/create-user.dto';
import { ApiBody, ApiOperation, ApiTags } from '@nestjs/swagger';
import { User } from '../user/entities/user.entity';
import { LoginDto } from '../user/dto/login.dto';
import { wx } from '../../config/config';
import { wxLoginDto } from '../user/dto/wxLogin.dto';

@ApiTags('public')
@Controller('user')
// 隐藏用户密码
@UseInterceptors(ClassSerializerInterceptor)
export class AuthController {
  constructor(private authService: AuthService) {}
  @Post('/createUser')
  @ApiOperation({
    summary: '添加用户/注册用户',
  })
  signUp(@Body() authCredentialsDto: CreateUserDto): Promise<User> {
    return this.authService.createUsers(authCredentialsDto);
  }
  @Post('/login')
  @ApiOperation({
    summary: '登录',
  })
  signIn(@Body() loginDto: LoginDto): Promise<{ token: string }> {
    return this.authService.signIns(loginDto);
  }
  @Post('/wx')
  @ApiOperation({
    summary: '微信登录',
  })
  getWx(@Body() wxLogin: wxLoginDto) {
    return this.authService.wxLogin(wxLogin);
  }
  @ApiOperation({ summary: '微信扫码地址' })
  @Get('wechatQr')
  wechatLogin() {
    return this.authService.wxQrcode();
  }
  @Get('/qq')
  @ApiOperation({
    summary: 'QQ登录',
  })
  getQQ() {
    return '未实现';
  }
}
